package cn.virens.web.components.shiro.oauth2.weixin;

import cn.virens.exception.APIException;
import cn.virens.oauth2.standard.Oauth2AccessTokenResponse;
import cn.virens.oauth2.weixin.standard.WeixinAccessTokenResponse;
import cn.virens.web.components.shiro.oauth2.PrincipalGetter;

public class WeixinPrincipalGetter extends PrincipalGetter {
	@Override
	protected Object get(Oauth2AccessTokenResponse respone) {
		if (respone instanceof WeixinAccessTokenResponse) {
			return ((WeixinAccessTokenResponse) respone).getOpenid();
		} else {
			throw new APIException("", "OAuth2 server not is WeiXin!");
		}
	}
}
